package com.jspgou.core.dao.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.jspgou.common.hibernate3.HibernateBaseDao;
import com.jspgou.core.dao.DbTplDao;
import com.jspgou.core.entity.DbTpl;

@Repository
public class DbTplDaoImpl extends HibernateBaseDao<DbTpl,String> implements DbTplDao {
	
	@SuppressWarnings("unchecked")
	public List<DbTpl> getChild(String path, boolean isDirectory) {
		StringUtils.replace(path, "_", "\\_");
		path=path+"/%";
		String notLike=path+"/%";
		String hql="from DbTpl bean"
				+ " where bean.id like ? and bean.id not like ?"
				+ " and bean.directory=? order by bean.id";
		return find(hql,path,notLike,isDirectory);
	}

	@Override
	protected Class<DbTpl> getEntityClass() {
		return DbTpl.class;
	}

}
